import java.text.DecimalFormat;

public class MyTime {
	private int hour=0;
	private int minute=0;
	private int second=0;
	public MyTime(){
		
	}
	public MyTime(int hour,int minute,int second){
		if(hour>=0&&hour<24)
		this.hour=hour;
		if(minute>=0&&minute<60)
		this.minute=minute;
		if(second>=0&&second<60)
		this.second=second;
	}
	public void setTime(int hour,int minute,int second){
		if(hour>=0&&hour<24)
		this.hour=hour;
		if(minute>=0&&minute<60)
		this.minute=minute;
		if(second>=0&&second<60)
		this.second=second;
	}
	public int getHour(){
		return hour;
	}
	public int getMinute(){
		return minute;
	}
	public int getSecond(){
		return second;
	}
	public void setHour(int hour){
		if(hour>=0&&hour<24)
			this.hour=hour;
	}
	public void setMinute(int minute){
		if(minute>=0&&minute<60)
			this.minute=minute;
	}
	public void setSecond(int second){
		if(second>=0&&second<60)
			this.second=second;
	}
	public String toString(){
		DecimalFormat f=new DecimalFormat("##00");
		String i =f.format(minute);
		String j =f.format(second);
		String k =f.format(hour);
		return 	k+":"+i+":"+j;
	}
	public MyTime nextSecond(){
		this.second++;
		if(second==60){
			second=0;
			minute++;
			if(minute==60){
				minute=0;
				hour++;
				if(hour==24){
					hour=0;
				}
			}
		}
		return this;
	}
	public MyTime nextMinute(){
		this.minute++;
		if(minute==60){
			minute=0;
			hour++;
			if(hour==24){
				hour=0;
			}
		}
		return this;
	}
	public MyTime nextHour(){
		this.hour++;
		if(hour==24){
			hour=0;
		}
		return this;
	}
	public MyTime previousSecond(){
		this.second--;
		if(second==-1){
			second=59;
			minute--;
			if(minute==-1){
				hour--;
				minute=59;
				if(hour==-1){
					hour=23;
				}
			}
		}
		return this;
	}
	public MyTime previousMinute(){
		this.minute--;
		if(minute==-1){
			hour--;
			minute=59;
			if(hour==-1){
				hour=23;
			}
		}
		return this;
	}
	public MyTime previousHour(){
		this.hour--;
		if(hour==-1){
			hour=23;
		}
		return this;
	}
}
